package models

import "gorm.io/gorm"

type Video struct {
	gorm.Model
	Userid       int    `gorm:"type:int(11);not null;comment:作者id" json:"userid"`
	VideoTitle   string `gorm:"type:varchar(30);not null;comment:视频标题" json:"video_title"`
	SubTitle     string `gorm:"type:varchar(30);not null;comment:视频子标题" json:"sub_title"`
	VideoUrl     string `gorm:"type:TEXT;not null;comment:视频地址" json:"video_url"`
	ImtUrl       string `gorm:"type:TEXT;not null;comment:封面图地址" json:"imt_url"`
	VideoType    int    `gorm:"type:int(1);not null;comment:视频类型" json:"video_type"`
	Address      string `gorm:"type:varchar(30);not null;comment:视频发布地点" json:"address"`
	LikeCount    int64  `gorm:"type:int(11);not null;comment:点赞量" json:"like"`
	CommentCount int64  `gorm:"type:int(11);not null;comment:评论" json:"comment_count"`
	LookCount    int64  `gorm:"type:int(11);not null;comment:观看量" json:"look_count"`
	BarrageCount int64  `gorm:"type:int(11);not null;comment:弹幕量" json:"barrage_count"`
	CangCount    int64  `gorm:"type:int(11);not null;comment:收藏量" json:"cang_count"`
	SendCount    int64  `gorm:"type:int(11);not null;comment:分享量" json:"send_count"`
	Status       int    `gorm:"type:tinyint(1);check:status In (0,1);not null;comment:视频权限" json:"status"`
}
type VideoType struct {
	gorm.Model
	TypeTitle string `gorm:"type:varchar(30);not null;comment:视频类型" json:"type_title"`
}

type VideoComment struct {
	gorm.Model
	Userid    int    `gorm:"type:int(11);not null;comment:用户id" json:"userid"`
	Comment   string `gorm:"type:TEXT;not null;comment:评论内容" json:"comment"`
	LikeCount int64  `gorm:"type:int(11);not null;comment:点赞量" json:"like"`
	Pid       int    `gorm:"type:int(11);not null;comment:父级评论id" json:"pid"`
}

func Migrate() error {
	return InitMysql(func(DB *gorm.DB) error {
		return DB.AutoMigrate(&Video{}, &VideoType{}, &VideoComment{})
	})
}
